var app = getApp();
let searchInput = -1;
Component({
  options: {
    addGlobalClass: true,
  },
  properties: {
    navTitle: {
      type: String,
      value: "",
    },
    back: {
      type: Boolean,
      value: false,
    },
    page: {
      type: String,
      value: "",
    },
  },
  data: {
    cityName: "广安市",
    cityCode: "511600",
    navBarHeight: app.globalData.navBarHeight,
    menuRight: app.globalData.menuRight,
    menuBottom: app.globalData.menuBottom,
    menuHeight: app.globalData.menuHeight,
    screenWidth: app.globalData.screenWidth,
  },
  methods: {
    inputSearch(e) {
      let searchKey = e.detail.value.trim();
      let clearShow = searchKey != "";
      this.setData({
        searchKey,
        clearShow,
      });
      this.inptTriggerEvent();
    },
    clearInput() {
      this.setData({
        searchKey: "",
        clearShow: false,
      });
      this.inptTriggerEvent();
    },
    //input触发

    inptTriggerEvent() {
      let searchKey = this.data.searchKey;
      clearTimeout(searchInput);
      searchInput = setTimeout(() => {
        this.triggerEvent("getSearchKey", searchKey);
      }, 900);
    },
  },
  created: function () {},
});
